//实现真正的懒加载，C#中实现单例模式的最佳实践
//延迟初始化
using System;

public class DeviceManagers
{
    // 私有构造函数，防止外部实例化
    private DeviceManagers()
    {
        Console.WriteLine("DeviceManagers instance created");
    }

    // 使用 Lazy<T> 实现延迟初始化
    private static readonly Lazy<DeviceManagers> _instanceHolder = new Lazy<DeviceManagers>(() => new DeviceManagers());

    // 公共静态属性，提供全局访问点
    public static DeviceManagers Instance => _instanceHolder.Value;

    public void DoSomething()
    {
        Console.WriteLine("Doing something");
    }
}
